/* Yhy App */
var YhyApp = angular.module("YhyApp", [
	"ui.router",
	"oc.lazyLoad"
]);

/* Setup App Main Controller */
YhyApp.controller('AppController', ['$scope', '$rootScope', function($scope, $rootScope) {
	$scope.$on('$viewContentLoaded', function() {

	});
}]);

/* Setup Layout Part - Header */
YhyApp.controller('HeaderController', ['$scope', function($scope) {
	$scope.$on('$includeContentLoaded', function() {
		
	});
}]);

/* Setup Layout Part - Top */
YhyApp.controller('TopController', ['$scope', function($scope) {
	$scope.$on('$includeContentLoaded', function() {
		
	});
}]);

/* Setup Layout Part - Footer */
YhyApp.controller('FooterController', ['$state','$scope', function($state, $scope) {
	$scope.$on('$includeContentLoaded', function() {
		
	});
}]);

/* Setup Rounting For All Pages */
YhyApp.config(['$stateProvider', '$urlRouterProvider', function($stateProvider, $urlRouterProvider) {
	// Redirect any unmatched url
	$urlRouterProvider.otherwise("/dashboard");

	$stateProvider
		.state('dashboard', {
			url: "/dashboard",
			templateUrl: "pages/dashboard.html",
			data: {
				pageTitle: '亿慧云'
			},
			controller: "dashboardController",
			resolve: {
				deps: ['$ocLazyLoad', function($ocLazyLoad) {
					return $ocLazyLoad.load({
						name: 'YhyApp',
						insertBefore: '#ng_load_plugins_before',
						files: [
							'js/controllers/dashboardController.js',
							'assets/global/js/swiper-3.4.2.min.js',
						]
					});
				}]
			}
		})	
		.state('search', {
			url: "/search",
			templateUrl: "pages/search.html",
			data: {
				pageTitle: '搜索'
			},
			controller: "searchController",
			resolve: {
				deps: ['$ocLazyLoad', function($ocLazyLoad) {
					return $ocLazyLoad.load({
						name: 'YhyApp',
						insertBefore: '#ng_load_plugins_before',
						files: [
							'js/controllers/searchController.js',
						]
					});
				}]
			}
		})	
		.state('physical-examination', {
			url: "/physical-examination",
			templateUrl: "pages/physical-examination.html",
			data: {
				pageTitle: '体检报告'
			},
			controller: "physical-examinationController",
			resolve: {
				deps: ['$ocLazyLoad', function($ocLazyLoad) {
					return $ocLazyLoad.load({
						name: 'YhyApp',
						insertBefore: '#ng_load_plugins_before',
						files: [
							'js/controllers/physical-examinationController.js',
						]
					});
				}]
			}
		})		
		.state('doctor', {
			url: "/doctor",
			templateUrl: "pages/doctor.html",
			data: {
				pageTitle: '医生解读'
			},
			controller: "doctorController",
			resolve: {
				deps: ['$ocLazyLoad', function($ocLazyLoad) {
					return $ocLazyLoad.load({
						name: 'YhyApp',
						insertBefore: '#ng_load_plugins_before',
						files: [
							'js/controllers/doctorController.js',
						]
					});
				}]
			}
		})	
		.state('business', {
			url: "/business",
			templateUrl: "pages/business.html",
			data: {
				pageTitle: '入驻商家'
			},
			controller: "businessController",
			resolve: {
				deps: ['$ocLazyLoad', function($ocLazyLoad) {
					return $ocLazyLoad.load({
						name: 'YhyApp',
						insertBefore: '#ng_load_plugins_before',
						files: [
							'js/controllers/businessController.js',
						]
					});
				}]
			}
		})		
		.state('lecture', {
			url: "/lecture",
			templateUrl: "pages/lecture.html",
			data: {
				pageTitle: '健康讲座'
			},
			controller: "lectureController",
			resolve: {
				deps: ['$ocLazyLoad', function($ocLazyLoad) {
					return $ocLazyLoad.load({
						name: 'YhyApp',
						insertBefore: '#ng_load_plugins_before',
						files: [
							'js/controllers/lectureController.js',
						]
					});
				}]
			}
		})		
		.state('bbs', {
			url: "/bbs",
			templateUrl: "pages/bbs.html",
			data: {
				pageTitle: '互动吧'
			},
			controller: "bbsController",
			resolve: {
				deps: ['$ocLazyLoad', function($ocLazyLoad) {
					return $ocLazyLoad.load({
						name: 'YhyApp',
						insertBefore: '#ng_load_plugins_before',
						files: [
							'js/controllers/bbsController.js',
						]
					});
				}]
			}
		})		
		.state('shop', {
			url: "/shop",
			templateUrl: "pages/shop.html",
			data: {
				pageTitle: '商城'
			},
			controller: "shopController",
			resolve: {
				deps: ['$ocLazyLoad', function($ocLazyLoad) {
					return $ocLazyLoad.load({
						name: 'YhyApp',
						insertBefore: '#ng_load_plugins_before',
						files: [
							'js/controllers/shopController.js',
							'assets/global/js/swiper-3.4.2.min.js',
											
						]
					});
				}]
			}
		})
		.state('my', {
			url: "/my",
			templateUrl: "pages/my.html",
			data: {
				pageTitle: '我的'
			},
			controller: "myController",
			resolve: {
				deps: ['$ocLazyLoad', function($ocLazyLoad) {
					return $ocLazyLoad.load({
						name: 'YhyApp',
						insertBefore: '#ng_load_plugins_before',
						files: [
							'js/controllers/myController.js',
						]
					});
				}]
			}
		})
		.state('product', {
			url: "/product",
			templateUrl: "pages/product.html",
			data: {
				pageTitle: '产品详情'
			},
			controller: "productController",
			resolve: {
				deps: ['$ocLazyLoad', function($ocLazyLoad) {
					return $ocLazyLoad.load({
						name: 'YhyApp',
						insertBefore: '#ng_load_plugins_before',
						files: [
							'js/controllers/productController.js',
							'assets/global/js/swiper-3.4.2.min.js',
						]
					});
				}]
			}
		})
		.state('recommend', {
			url: "/recommend",
			templateUrl: "pages/recommend.html",
			data: {
				pageTitle: '推荐'
			},
			controller: "recommendController",
			resolve: {
				deps: ['$ocLazyLoad', function($ocLazyLoad) {
					return $ocLazyLoad.load({
						name: 'YhyApp',
						insertBefore: '#ng_load_plugins_before',
						files: [
							'js/controllers/recommendController.js',
							
						]
					});
				}]
			}
		})
		.state('cart', {
			url: "/cart",
			templateUrl: "pages/cart.html",
			data: {
				pageTitle: '购物车'
			},
			controller: "cartController",
			resolve: {
				deps: ['$ocLazyLoad', function($ocLazyLoad) {
					return $ocLazyLoad.load({
						name: 'YhyApp',
						insertBefore: '#ng_load_plugins_before',
						files: [
							'js/controllers/cartController.js',
							
						]
					});
				}]
			}
		})
		.state('collection', {
			url: "/collection",
			templateUrl: "pages/collection.html",
			data: {
				pageTitle: '收藏'
			},
			controller: "collectionController",
			resolve: {
				deps: ['$ocLazyLoad', function($ocLazyLoad) {
					return $ocLazyLoad.load({
						name: 'YhyApp',
						insertBefore: '#ng_load_plugins_before',
						files: [
							'js/controllers/collectionController.js',
							
						]
					});
				}]
			}
		})
		.state('deliver', {
			url: "/deliver",
			templateUrl: "pages/deliver.html",
			data: {
				pageTitle: '物流信息'
			},
			controller: "deliverController",
			resolve: {
				deps: ['$ocLazyLoad', function($ocLazyLoad) {
					return $ocLazyLoad.load({
						name: 'YhyApp',
						insertBefore: '#ng_load_plugins_before',
						files: [
							'js/controllers/deliverController.js',
							
						]
					});
				}]
			}
		})
		.state('sort', {
			url: "/sort",
			templateUrl: "pages/sort.html",
			data: {
				pageTitle: '分类'
			},
			controller: "sortController",
			resolve: {
				deps: ['$ocLazyLoad', function($ocLazyLoad) {
					return $ocLazyLoad.load({
						name: 'YhyApp',
						insertBefore: '#ng_load_plugins_before',
						files: [
							'js/controllers/sortController.js',
						]
					});
				}]
			}
		})
		.state('login', {
			url: "/login",
			templateUrl: "pages/login.html",
			data: {
				pageTitle: '登录'
			},
			controller: "loginController",
			resolve: {
				deps: ['$ocLazyLoad', function($ocLazyLoad) {
					return $ocLazyLoad.load({
						name: 'YhyApp',
						insertBefore: '#ng_load_plugins_before',
						files: [
							'js/controllers/loginController.js',
						]
					});
				}]
			}
		})
		.state('register', {
			url: "/register",
			templateUrl: "pages/register.html",
			data: {
				pageTitle: '注册'
			},
			controller: "registerController",
			resolve: {
				deps: ['$ocLazyLoad', function($ocLazyLoad) {
					return $ocLazyLoad.load({
						name: 'YhyApp',
						insertBefore: '#ng_load_plugins_before',
						files: [
							'js/controllers/registerController.js',
						]
					});
				}]
			}
		})
		.state('order', {
			url: "/order",
			templateUrl: "pages/order.html",
			data: {
				pageTitle: '订单'
			},
			controller: "orderController",
			resolve: {
				deps: ['$ocLazyLoad', function($ocLazyLoad) {
					return $ocLazyLoad.load({
						name: 'YhyApp',
						insertBefore: '#ng_load_plugins_before',
						files: [
							'js/controllers/orderController.js',						
						]
					});
				}]
			}
		})
		.state('spread', {
			url: "/spread",
			templateUrl: "pages/spread.html",
			data: {
				pageTitle: '我的分销'
			},
			controller: "spreadController",
			resolve: {
				deps: ['$ocLazyLoad', function($ocLazyLoad) {
					return $ocLazyLoad.load({
						name: 'YhyApp',
						insertBefore: '#ng_load_plugins_before',
						files: [
							'js/controllers/spreadController.js',						
						]
					});
				}]
			}
		})
		.state('commission', {
			url: "/commission",
			templateUrl: "pages/commission.html",
			data: {
				pageTitle: '我的提成'
			},
			controller: "commissionController",
			resolve: {
				deps: ['$ocLazyLoad', function($ocLazyLoad) {
					return $ocLazyLoad.load({
						name: 'YhyApp',
						insertBefore: '#ng_load_plugins_before',
						files: [
							'js/controllers/commissionController.js',						
						]
					});
				}]
			}
		})
		.state('forget', {
			url: "/forget",
			templateUrl: "pages/forget.html",
			data: {
				pageTitle: '我的提成'
			},
			controller: "forgetController",
			resolve: {
				deps: ['$ocLazyLoad', function($ocLazyLoad) {
					return $ocLazyLoad.load({
						name: 'YhyApp',
						insertBefore: '#ng_load_plugins_before',
						files: [
							'js/controllers/forgetController.js',						
						]
					});
				}]
			}
		})
		.state('reward', {
			url: "/reward",
			templateUrl: "pages/reward.html",
			data: {
				pageTitle: '直接奖励总额'
			},
			controller: "rewardController",
			resolve: {
				deps: ['$ocLazyLoad', function($ocLazyLoad) {
					return $ocLazyLoad.load({
						name: 'YhyApp',
						insertBefore: '#ng_load_plugins_before',
						files: [
							'js/controllers/rewardController.js',						
						]
					});
				}]
			}
		})
		.state('reward02', {
			url: "/reward02",
			templateUrl: "pages/reward02.html",
			data: {
				pageTitle: '间接奖励总额'
			},
			controller: "reward02Controller",
			resolve: {
				deps: ['$ocLazyLoad', function($ocLazyLoad) {
					return $ocLazyLoad.load({
						name: 'YhyApp',
						insertBefore: '#ng_load_plugins_before',
						files: [
							'js/controllers/reward02Controller.js',						
						]
					});
				}]
			}
		})
		.state('sp-client', {
			url: "/sp-client",
			templateUrl: "pages/sp-client.html",
			data: {
				pageTitle: '我的直接客户'
			},
			controller: "sp-clientController",
			resolve: {
				deps: ['$ocLazyLoad', function($ocLazyLoad) {
					return $ocLazyLoad.load({
						name: 'YhyApp',
						insertBefore: '#ng_load_plugins_before',
						files: [
							'js/controllers/sp-clientController.js',						
						]
					});
				}]
			}
		})
		.state('sp-client02', {
			url: "/sp-client02",
			templateUrl: "pages/sp-client02.html",
			data: {
				pageTitle: '我的间接客户'
			},
			controller: "sp-client02Controller",
			resolve: {
				deps: ['$ocLazyLoad', function($ocLazyLoad) {
					return $ocLazyLoad.load({
						name: 'YhyApp',
						insertBefore: '#ng_load_plugins_before',
						files: [
							'js/controllers/sp-client02Controller.js',						
						]
					});
				}]
			}
		})
		.state('qr-code', {
			url: "/qr-code",
			templateUrl: "pages/qr-code.html",
			data: {
				pageTitle: '我的二维码'
			},
			controller: "qr-codeController",
			resolve: {
				deps: ['$ocLazyLoad', function($ocLazyLoad) {
					return $ocLazyLoad.load({
						name: 'YhyApp',
						insertBefore: '#ng_load_plugins_before',
						files: [
							'js/controllers/qr-codeController.js',						
						]
					});
				}]
			}
		})
		.state('withdraw', {
			url: "/withdraw",
			templateUrl: "pages/withdraw.html",
			data: {
				pageTitle: '提现'
			},
			controller: "withdrawController",
			resolve: {
				deps: ['$ocLazyLoad', function($ocLazyLoad) {
					return $ocLazyLoad.load({
						name: 'YhyApp',
						insertBefore: '#ng_load_plugins_before',
						files: [
							'js/controllers/withdrawController.js',						
						]
					});
				}]
			}
		})
		.state('change-list', {
			url: "/change-list",
			templateUrl: "pages/change-list.html",
			data: {
				pageTitle: '提成明细列表'
			},
			controller: "change-listController",
			resolve: {
				deps: ['$ocLazyLoad', function($ocLazyLoad) {
					return $ocLazyLoad.load({
						name: 'YhyApp',
						insertBefore: '#ng_load_plugins_before',
						files: [
							'js/controllers/change-listController.js',						
						]
					});
				}]
			}
		})
		.state('change-detail', {
			url: "/change-detail",
			templateUrl: "pages/change-detail.html",
			data: {
				pageTitle: '提成明细'
			},
			controller: "change-detailController",
			resolve: {
				deps: ['$ocLazyLoad', function($ocLazyLoad) {
					return $ocLazyLoad.load({
						name: 'YhyApp',
						insertBefore: '#ng_load_plugins_before',
						files: [
							'js/controllers/change-detailController.js',						
						]
					});
				}]
			}
		})
		.state('add-card', {
			url: "/add-card",
			templateUrl: "pages/add-card.html",
			data: {
				pageTitle: '添加银行卡'
			},
			controller: "add-cardController",
			resolve: {
				deps: ['$ocLazyLoad', function($ocLazyLoad) {
					return $ocLazyLoad.load({
						name: 'YhyApp',
						insertBefore: '#ng_load_plugins_before',
						files: [
							'js/controllers/add-cardController.js',						
						]
					});
				}]
			}
		})
		.state('test', {
			url: "/test",
			templateUrl: "pages/test.html",
			data: {
				pageTitle: '测试'
			},
			controller: "testController",
			resolve: {
				deps: ['$ocLazyLoad', function($ocLazyLoad) {
					return $ocLazyLoad.load({
						name: 'YhyApp',
						insertBefore: '#ng_load_plugins_before',
						files: [
							'js/controllers/testController.js',
							'assets/global/js/swiper-3.4.2.min.js',
						]
					});
				}]
			}
		})
		
}]);